package cn.dhnep.demo.controller;


import cn.dhnep.demo.pojo.Earnings;
import cn.dhnep.demo.pojo.Order;
import cn.dhnep.demo.pojo.Recharge;
import cn.dhnep.demo.pojo.Withdraw;
import cn.dhnep.demo.service.WithdrawService;
import cn.dhnep.demo.util.Page;
import cn.dhnep.demo.util.ResultMap;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  提现模块
 * </p>
 *
 * @author dhn
 * @since 2021-08-19
 */
@RestController
@RequestMapping("/withdraw")
public class WithdrawController {

    @Resource
    private WithdrawService withdrawService;

    private Map<String,Object> result = new HashMap<>();


    @ApiOperation("提现订单查询")
    @RequestMapping("withdraw")
    public ResultMap<List<Withdraw>> WithdrawList(String phone,String userType,Page page, @RequestParam("limit") Integer limit){
        page.setRows(limit);
        if (phone!=null){
            page.setPhone(phone);
        }
        if (userType!=null){
            page.setUserType(userType);
        }
        List<Withdraw>withdrawList=withdrawService.selectPageList(page);
        int totals=withdrawService.selectPageCount(page);
        page.setTotalRecord(totals);
        return new ResultMap<List<Withdraw>>("",withdrawList,0,totals);
    }

    @ApiOperation("充值订单查询")
    @RequestMapping("recharge")
    public ResultMap<List<Recharge>> RechargeList(String phone, String userType, Page page, @RequestParam("limit") Integer limit){
        page.setRows(limit);
        List<Recharge>withdrawList=withdrawService.selectRechargePageList(page);
        int totals=withdrawService.selectPageCount(page);
        page.setTotalRecord(totals);
        return new ResultMap<List<Recharge>>("",withdrawList,0,totals);
    }


    @ApiOperation("支付记录查询")
    @RequestMapping("earnings")
    public ResultMap<List<Earnings>> EarningsList(Page page, @RequestParam("limit") Integer limit){
        page.setRows(limit);
        List<Earnings>earningsList=withdrawService.selectEarningsPageList(page);
        int totals=withdrawService.selectEarningsPageCount(page);
        page.setTotalRecord(totals);
        return new ResultMap<List<Earnings>>("",earningsList,0,totals);
    }


}

